<!DOCTYPE html>
<html lang="zh-CN"
	xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	layout:decorator="layout/default">
<head>
<meta charset="UTF-8">
<title>账号管理</title>
    <script th:src="@{/assets/scripts/search.js}"></script>
<script>
	$(document).ready(function (){
		Search.searchKeyUp();
	});
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		if(n==null || n == ""){
			$(".real-key").val($(".show-key").val());
		}
		$("#userSearchForm").submit();
		return false;
	}
</script>
</head>
<body>
	<div layout:fragment="content" th:remove="tag" shiro:has-permission="sys:user:view">
		<div
			th:replace="fragments/tool :: tipMessage (type='',content=${message})"
			th:remove="tag"></div>
		<div class="row">
			<div class="col-md-12">
				<!-- BEGIN PAGE TITLE & BREADCRUMB-->
				<ul class="page-breadcrumb breadcrumb">
					<li><i class="fa fa-home"></i> <a th:href="@{/}">首页</a> <i
						class="fa fa-angle-right"></i></li>
					<li><a href="#">权限管理</a> <i class="fa fa-angle-right"></i></li>
					<li><a th:href="@{/sys/user}">账号管理</a></li>
				</ul>
				<!-- END PAGE TITLE & BREADCRUMB-->

			</div>
		</div>
		<div class="row profile">
			<div class="col-md-12">
				<!--BEGIN TABS-->
				<div class="tabbable tabbable-custom tabbable-full-width">
					<div class="tab-content">

						<div class="tab-pane active" id="user_tab_1_1">
							<div class="row search-form-default alert alert-info">
								<div class="col-md-7">
									<form id="userSearchForm" th:object="${user}"
										th:action="@{/sys/user/}" method="post" class="form-inline">
										<input id="pageNo" name="pageNo" type="hidden"
											th:value="${page.pageNo}" /> <input id="pageSize"
											name="pageSize" type="hidden" th:value="${page.pageSize}" />
										<input id="orderBy" name="orderBy" type="hidden"
											th:value="${page.orderBy}" />

										<div class="input-group input-xlarge">

											<!-- /btn-group -->
											<input type="text" th:value="${user.realName}" class="form-control show-key" maxlength="100" />
											
											<input type="hidden" class="form-control real-key" 
												th:field="*{realName}" maxlength="100" />	
												

											<div class="input-group-btn">
												<button type="button" class="btn green search-button" 
													onclick="return page();">
													搜索 &nbsp;<i class="m-icon-swapright m-icon-white"></i>
												</button>
											</div>
											<!-- /btn-group -->

										</div>
									</form>
								</div>
								<div class="col-md-5" style="text-align: right;">
									<a th:href="@{/sys/user/form}" class="btn blue" shiro:has-permission="sys:user:add"><span> + 账号添加</span></a>
								</div>

							</div>

							<div class="table-responsive">
								<table
									class="table table-striped table-bordered table-advance table-hover">
									<thead>
										<tr>
											<th>序号</th>
											<th>账号名称</th>
											<th>真实姓名</th>
											<th>所属机构</th>
											<th>所在部门</th>
											<th>账号状态</th>
											<th>拥有角色</th>
											<th shiro:has-any-permissions="sys:user:edit,sys:user:delete">操作</th>
										</tr>
									</thead>
									<tbody>
										<tr th:each="user,iterStat : ${page.list}">
											<td th:text="${user.index}"></td>
											<td><p class="ellipsis">
												<th:block th:text="${user.loginName}"></th:block>
											</p></td>
											<td><p class="ellipsis">
													<th:block th:text="${user.realName}" />
												</p></td>
											<td><p class="ellipsis">
													<th:block th:text="${user.company.name}" />
												</p></td>
											<td><p class="ellipsis">
													<th:block th:text="${user.office.name}" />
												</p></td>
											<td><th:block
													th:if="${#strings.equals(user.state, '0') or #strings.equals(user.state, '1')}">
													<span>正常</span>
												</th:block> <th:block th:if="${#strings.equals(user.state, '2')}">
													<span style="color: red;">冻结</span>
												</th:block></td>
											<td><p class="ellipsis">
													<th:block th:text="${user.roleNames}"></th:block>
												</p></td>
											<td shiro:has-any-permissions="sys:user:edit,sys:user:delete"><th:block
													th:if="${#strings.equals(user.state, '0') or #strings.equals(user.state, '1')}">
													<a class="btn default btn-xs blue-stripe" 
														th:href="@{/sys/user/changeState(id=${user.id},state=2)}"
														th:attr="data-title=${user.loginName}"
														onclick="return App.confirm('确认冻结账号吗？', this.href)" shiro:has-permission="sys:user:edit">冻结</a>
												</th:block> <th:block th:if="${#strings.equals(user.state, '2')}">
													<a class="btn default btn-xs red-stripe" 
														th:href="@{/sys/user/changeState(id=${user.id},state=0)}"
														th:attr="data-title=${user.loginName}"
														onclick="return App.confirm('确认解冻账号吗？', this.href)" shiro:has-permission="sys:user:edit">解冻</a>
												</th:block> <a class="btn default btn-xs blue-stripe"
												th:href="@{/sys/user/form(id=${user.id})}"
												th:attr="data-title=${user.loginName}" shiro:has-permission="sys:user:edit">修改</a> <a
												class="btn default btn-xs red-stripe"
												th:href="@{/sys/user/delete(id=${user.id})}"
												th:attr="data-title=${user.loginName}"
												onclick="return App.confirm('删除该账号将解除与该账号绑定的所有设备关系，是否删除？', this.href)" shiro:has-permission="sys:user:delete">删除</a>

											</td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="row margin-top-20">
								<th:block th:utext="${page}" />
							</div>

						</div>
					</div>
				</div>
			</div>


		</div>
	</div>
</body>
</html>
